package apis

import (
	"k8sdev/pkg/services"
	"log"
	"net/http"

	"github.com/gin-gonic/gin"
)

func GetPods(c *gin.Context) {
	podsList := make([]string, 0)
	namespace := c.Param("namespaceName")
	pods, err := services.GetPods(namespace)
	if err != nil {
		log.Fatal(err)
		return
	}
	for _, podName := range *pods {
		podsList = append(podsList, podName.Name)
	}
	c.JSON(http.StatusOK, gin.H{
		"pods": podsList,
	})
}
